package com.atguigu.yygh.order.controller;

import com.atguigu.yygh.common.result.R;
import com.atguigu.yygh.order.service.WeiPayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author:hx
 * @DateTime:2022/11/19 10:20
 * @Description:
 */
@RestController
@RequestMapping("/order/weipay")
public class WeiPayController {

    @Autowired
    private WeiPayService weiPayService;

    @GetMapping("/createNative/{orderId}")
    public R createNative(@PathVariable Long orderId) {
        String url = weiPayService.createNative(orderId);
        return R.ok().data("url", url);
    }

    @GetMapping("/queryPayStatus/{orderId}")
    public R queryPayStatus(@PathVariable Long orderId) {
        String message = weiPayService.queryPayStatus(orderId);
        return R.ok().message(message);
    }
}
